﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess.Classes;

namespace Webmau.Admin.Control
{
    public partial class QuanLiNguoiDung : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnDanhSach_Click(object sender, EventArgs e)
        {
            gvDanhSach.DataSource = NguoiDung1.LayTatCa();
            gvDanhSach.DataBind();
        }
        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }
        protected void btnTim_Click(object sender, EventArgs e)
        {
            gvDanhSach.DataSource = NguoiDung1.TimKiem(txtTim.Text);
            gvDanhSach.DataBind();
        }
        protected void gvDanhSach_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                int hang = int.Parse(e.CommandArgument.ToString());
                string cot = gvDanhSach.Rows[hang].Cells[0].Text;
                if (e.CommandName == "Delete")
                {
                    NguoiDung1.Xoa(cot);
                    Response.Redirect("~/Admin/QuanLiUser.aspx");
                    btnDanhSach_Click(sender, e);
                }
            }
            catch
            {
            }
        }
        protected void btnAdmin_Click(object sender, EventArgs e)
        {
            gvDanhSach.DataSource = NguoiDung1.LayTatCaAdmin();
            gvDanhSach.DataBind();
        }
    }
}